package cn.edu.jxau.test;

import java.util.Arrays;
import java.util.Objects;

public class Main {

	public static void main(String[] args) {

		foo(new int[] { 1, 2, 4, 7, 11, 15 }, 15);

	}

	public static void foo(int[] arr, int sum) {

		// 1.参数校验 //
		Objects.requireNonNull(arr, "参数arr不为null");
		int low = 0;
		int high = arr.length - 1;
		while (low < high) {
			int t = arr[low] + arr[high];
			if (t < sum) {
				low++;
			} else if (t > sum) {
				high--;
			} else {
				System.out.println(low + "\t" + high);
				return;
			}
		}
	}
}